From 4665a2b24255c9de6fabf87a303a59d1318e39d7 Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Mon, 1 Mar 2004 17:04:00 +0000 Subject: [PATCH] bitkeeper revision 1.760 (40436d00pAWlfO-5kOcLlyUpl-Vl0Q) event_channel.c, xend.c, Makefile, xc_domain.c, xc.h: Another point on the way to shared comms rings. The console concentrator is coming along. --- tools/xc/lib/xc.h | 1 + tools/xc/lib/xc_domain.c | 1 + tools/xend/Makefile | 4 +- tools/xend/xend.c | 184 ++++++++++++++++++++++++++++++++++++- xen/common/event_channel.c | 4 + 5 files changed, 191 insertions(+), 3 deletions(-) diff --git a/tools/xc/lib/xc.h b/tools/xc/lib/xc.h index 907aa56c30..2f2d26919e 100644 --- a/tools/xc/lib/xc.h +++ b/tools/xc/lib/xc.h @@ -28,6 +28,7 @@ typedef struct { int has_cpu; int stopped; unsigned long nr_pages; + unsigned long shared_info_frame; u64 cpu_time; #define XC_DOMINFO_MAXNAME 16 char name[XC_DOMINFO_MAXNAME]; diff --git a/tools/xc/lib/xc_domain.c b/tools/xc/lib/xc_domain.c index 759e3ecfc7..4d68f5d937 100644 --- a/tools/xc/lib/xc_domain.c +++ b/tools/xc/lib/xc_domain.c @@ -91,6 +91,7 @@ int xc_domain_getinfo(int xc_handle, info->has_cpu = op.u.getdomaininfo.has_cpu; info->stopped = (op.u.getdomaininfo.state == DOMSTATE_STOPPED); info->nr_pages = op.u.getdomaininfo.tot_pages; + info->shared_info_frame = op.u.getdomaininfo.shared_info_frame; info->cpu_time = op.u.getdomaininfo.cpu_time; strncpy(info->name, op.u.getdomaininfo.name, XC_DOMINFO_MAXNAME); info->name[XC_DOMINFO_MAXNAME-1] = '\0'; diff --git a/tools/xend/Makefile b/tools/xend/Makefile index 1fb84e0aaf..ab31f8c628 100644 --- a/tools/xend/Makefile +++ b/tools/xend/Makefile @@ -1,7 +1,7 @@ CC = gcc CFLAGS = -Wall -O3 -CFLAGS += -I../../xen/include -I../../xenolinux-sparse/include +CFLAGS += -I../xc/lib HDRS = $(wildcard *.h) OBJS = $(patsubst %.c,%.o,$(wildcard *.c)) @@ -24,7 +24,7 @@ clean: $(RM) *.a *.so *.o *.rpm $(BIN) $(BIN): $(OBJS) - $(CC) $(CFLAGS) -o $@ $^ -L../xc/lib -lxc + $(CC) -o $@ $^ -L../xc/lib -lxc %.o: %.c $(HDRS) Makefile $(CC) $(CFLAGS) -c -o $@ $< diff --git a/tools/xend/xend.c b/tools/xend/xend.c index 9da656e0a1..208db8da0d 100644 --- a/tools/xend/xend.c +++ b/tools/xend/xend.c @@ -1,12 +1,194 @@ /****************************************************************************** * xend.c * - * The grand Xen daemon. For now it's just a console concentrator. + * The grand Xen daemon. For now it's just a virtual-console concentrator. * * Copyright (c) 2004, K A Fraser */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* NB. The following should be kept in sync with the kernel's evtchn driver. */ +#define EVTCHN_DEV_NAME "/dev/xen/evtchn" +#define EVTCHN_DEV_MAJOR 10 +#define EVTCHN_DEV_MINOR 200 +#define PORT_NORMAL 0x0000 /* A standard event notification. */ +#define PORT_DISCONNECT 0x8000 /* A port-disconnect notification. */ +#define PORTIDX_MASK 0x7fff /* Strip subtype to obtain port index. */ +#define EVTCHN_RESET _IO('E', 1) /* Clear notification buffer. Clear errors. */ + +/* Error macros. */ +#define ERROR(_f, _a...) \ + fprintf ( stderr, "ERROR: " _f "\n" , ## _a ); +#define SYS_ERROR(_f, _a...) \ + fprintf ( stderr, "ERROR: " _f " [errno=%d (%s)]\n" , \ + ## _a , errno , strerror(errno) ); +#define HINT(_f, _a...) \ + fprintf ( stderr, "Hint: " _f "\n" , ## _a ); +#define ROOT_HINT() HINT("You must execute this daemon as root.") +#define DOM0_HINT() HINT("You must execute this daemon " \ + "on a privileged Xenolinux instance (e.g., DOM0).") + +/* The following is to be shared with guest kernels. */ +typedef struct { + u8 cmd_type; /* echoed in response */ + u8 cmd_subtype; /* echoed in response */ + u8 id; /* echoed in response */ + u8 length; /* number of bytes in 'msg' */ + unsigned char msg[60]; /* command-specific message data */ +} control_msg_t; +#define CONTROL_RING_SIZE 8 +typedef unsigned int CONTROL_RING_IDX; +#define MASK_CONTROL_IDX(_i) ((_i)&(CONTROL_RING_SIZE-1)) +typedef struct { + control_msg_t tx_ring[CONTROL_RING_SIZE]; /* guest -> DOM0 */ + control_msg_t rx_ring[CONTROL_RING_SIZE]; /* DOM0 -> guest */ + CONTROL_RING_IDX tx_req_prod, tx_resp_prod; + CONTROL_RING_IDX rx_req_prod, rx_resp_prod; +} control_comms_t; +#define CMD_CONSOLE 0 +#define CMD_CONSOLE_DATA 0 + +#define PAGE_SHIFT 12 +#define PAGE_SIZE (1<event_channel[port2].remote_port = (u16)port1; p2->event_channel[port2].state = ECS_CONNECTED; + /* Ensure that the disconnect signal is not asserted. */ + clear_bit(port1, &p1->shared_info->event_channel_disc[0]); + clear_bit(port2, &p2->shared_info->event_channel_disc[0]); + cpu_mask = set_event_pending(p1, port1); cpu_mask |= set_event_pending(p2, port2); guest_event_notify(cpu_mask); -- 2.30.2